﻿using WinForm.CommunityToolkit.Generators.ViewModels;

namespace WinForm.CommunityToolkit.Generators.Views
{
    public partial class PersonView : Form
    {
        private PersonViewModel viewModel;
        public PersonView()
        {
            InitializeComponent();

            viewModel = new PersonViewModel();

            // 设置数据绑定
            txtName.DataBindings.Add("Text", viewModel.Person, "Name", false, DataSourceUpdateMode.OnPropertyChanged);
            txtAge.DataBindings.Add("Text", viewModel.Person, "Age", false, DataSourceUpdateMode.OnPropertyChanged);

            btnSave.Click += (s, e) => viewModel.SaveCommand.Execute(null);
        }
    }
}
